﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FantastPlatform.Framework.IModel;
using FantastPlatform.Framework.Model;

namespace FantastPlatform.Framework.IService
{
    public interface IRoleService : IDataService<IRole>
    {
        /// <summary>
        /// 检查权限
        /// </summary>
        /// <param name="resource">权限资源</param>
        /// <param name="Operation">权限行为</param>
        /// <returns>是否拥有该权限</returns>
        bool CheckRight(IResource resource, IOperation operation);
        /// <summary>
        /// 得到指定用户下没有添加的角色
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        IList<IRole> LoadRolesNotExsit(string keywords, int userId, int page, int pageSize, out int totoalCount);
        /// <summary>
        /// 通过角色ID得到该角色下的用户
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        IList<IUser> GetUsers(int roleId, int page, int pageSize, out int totoalCount);
        /// <summary>
        /// 通过角色ID得到该角色下的许可
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        IList<IPermission> GetPermissions(int roleId, int page, int pageSize, out int totoalCount);
        /// <summary>
        /// 为角色添加用户
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="roleIds"></param>
        void AddUsers(int roleId, IList<int> userIds);
        /// <summary>
        /// 移除角色用户
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="roleIds"></param>
        void RemoveUsers(int roleId, IList<int> userIds);
        /// <summary>
        /// 更新角色许可
        /// </summary>
        /// <param name="role"></param>
        void UpdateRolePermissions(int roleId, IList<int> permissionIds);
    }
}
